<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>

    </style>
    <script>
        function css(obj,name,value){
           // alert(obj==arguments[0]);//验证obj与arguments[0]是否相等
            if(arguments.length==2){//获取
                return obj.style[name];
            }
            else{
                obj.style[name]=value;//设置
            }
        }
        window.onload=function(){
            var oDiv=document.getElementById('div1');
            //alert(css(oDiv,'width')); //获取
            css(oDiv,'background','green'); //设置

        }
    </script>
</head>
<body>
<div id="div1" style="width:200px; height:200px; background:red;"></div>
</body>
</html>
<!--css(oDiv,'width')-> 获取样式
<!--css(oDiv,'width','200px')-> 设置样式